$(function() {
    var $el = $('#headquote');
	$el.data('quotes', {
		quotes: [
			{quote: 'A memory is what is left when something happens and does not completely unhappen', source: 'Edward de Bono'},
			{quote: 'Cherish all your happy moments: they fine a fine cushion for old age', source: 'Tarkington Booth'},
			{quote: 'Every goodbye is the birth of a memory', source: 'Dutch Proverb'},
			{quote: 'How we remember, what we remember, and why we remember form the most personal map of our individuality', source: 'Christina Baldwin'},
			{quote: 'I have more memories than if I were a thousand years old', source: 'Charles Baudelaire'},
			{quote: 'I wear the key of memory, and can open every door in the house of my life', source: 'Amelia E. Barr'},
			{quote: 'In memory everything seems to happen to music', source: 'Tennessee Williams'},
			{quote: 'Memories of our lives, of our works and our deeds will continue in others', source: 'Rosa Parks'},
			{quote: 'Memory\'s the very skin of life', source: 'Elizabeth Hardwick'},
			{quote: 'Memory is a man\'s real possession . In nothing else is he rich, in nothing else is he poor', source: 'Alexander Smith'},
			{quote: 'Memory is the diary that we all carry about with us', source: 'Oscar Wilde'},
			{quote: 'They may forget what you said, but they will never forget how you made them feel', source: 'Carl W. Buechner'},
			{quote: 'We all have our time machines. Some take us back, they are called memories. Some take us forward, they are called dreams', source: 'Jeremy Irons'},
			{quote: 'We do not know the true value of our moments unitl they have undergone the test of memory', source: 'Georges Duhamel'},
			{quote: 'We do not remember days;<br>we remember moments', source: 'Cesare Pavese'}
		],
		selected: 0
	});
	showQuote();
    setInterval(showQuote, 5000);
    function showQuote() {
        var $el = $('#headquote');
        var obj = $el.data('quotes');
        var selected = obj.selected;
        var quote = obj.quotes[selected];
        var quotesLen = obj.quotes.length;
        var $oldQuote = $('p', $el);
        var newQuote = document.createElement('p');
        $(newQuote).html(quote.quote + ' <span>- ' + quote.source + '</span>');
        $(newQuote).hide();
        $el.get(0).appendChild(newQuote);
        $oldQuote.ClearTypeFadeOut(2000, function () {
            $(newQuote).ClearTypeFadeIn(2000, function () {
                $oldQuote.remove();
            });
        });
        obj.selected = (selected + 1) % quotesLen;
    }
});
